package com.zline.foodraise;

import android.app.Application;
import android.content.Context;

import com.baidu.mobstat.StatService;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.cache.memory.impl.UsingFreqLimitedMemoryCache;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
import com.nostra13.universalimageloader.core.download.BaseImageDownloader;
import com.nostra13.universalimageloader.utils.StorageUtils;
import com.zline.foodraise.util.LUtil;

import org.androidannotations.annotations.EApplication;

import java.io.File;

import cn.jpush.android.api.JPushInterface;

/**
 * Created by heshantao on 15/6/23.
 */
@EApplication
public class ZlineApplication extends Application {
    private static final String LOG_TAG=ZlineApplication.class.getSimpleName();
    @Override
    public void onCreate() {
        super.onCreate();
        initImageLoader(getApplicationContext());
        StatService.setDebugOn(true);
        JPushInterface.init(this);

    }


    //imageLoader 初始化设置
    public static void initImageLoader(Context context) {
        File cashFile=new File(StorageUtils.getCacheDirectory(context),"images");
        //缓存文件的目录
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
                .threadPriority(Thread.NORM_PRIORITY - 2)
                .diskCache(new UnlimitedDiskCache(cashFile))//设置sd卡存储的目录
                .diskCacheFileNameGenerator(new Md5FileNameGenerator()) //将保存的时候的URI名称用MD5 加密
                .tasksProcessingOrder(QueueProcessingType.LIFO)//队列处理后进先出
                .build();
        //全局初始化此配置
        ImageLoader.getInstance().init(config);
    }
}
